// 引入其他JS文件
document.write("<script type='text/javascript' src='/static/js/common/common.js'></script>");

/**
 * 全部人员管理动态控制按钮显示 ss
 * @param e
 * @returns {string}
 */
function autoOperate(e) {
    var record = e.value;
    var arr = record.split("@");
    var loginUserLevel = arr[0];
    var pstate = arr[1];
    var xd = arr[3];
    var s = "";
    //司法厅或地市司法局或区县司法局
    if (loginUserLevel == "06" || loginUserLevel == "07" || loginUserLevel == "08") {
        //只有查看操作
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp'
    //司法所
    } else if (loginUserLevel == "03") {
        //其他服刑人员的查看和编辑和设置帮教小组
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toSetBjxz()"  >&nbsp;&nbsp;设置帮教小组&nbsp;&nbsp;</a>&nbsp'
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toEdit()"  >&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp'
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp'
        //判断xd是戒毒中状态，如果是，则增加解除按钮
        if (xd == "1") {
            s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toRemove()"  >&nbsp;&nbsp;解除戒毒&nbsp;&nbsp;</a>&nbsp'
        }
    } else {//以防其他角色分配到该功能
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp'
    }
    return s;
}

function toRemove() {
    var row = grid.getSelected();
    toRemoveDrug(row.priNum);
}

//全部人员管理新增
function add() {
    mini.open({
        url: "/azbj/bjdxInfo/qbrygl/addBaseInfo/view",
        title: "新增",
        width: "50%",
        height: "80%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//全部人员管理设置帮教小组
function toSetBjxz() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/qbrygl/toAllTab/view?priNum=" + row.priNum +"&type=" + 0,
        title: "设置帮教小组",
        width: "65%",
        height: "85%",
        allowDrag: true,
        allowResize: true,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });

}

/**
 * 编辑服刑人员录入的信息
 */
function toEdit() {
    var rows = grid.getSelecteds();
    if (rows.length > 1) {
        mini.alert("请勾选一条数据再编辑");

    } else {
        var row = grid.getSelected();
        if (row) {
            mini.open({
                url: "/azbj/bjdxInfo/qbrygl/editBaseInfo/view?priNum=" + row.priNum + "&pmid=" + row.pmid,
                title: "编辑服刑人员信息", width: '68%', height: '80%',
                onload: function () {
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        } else {
            mini.alert("请至少选择一条数据！");
        }
    }
}

//全部人员管理--查看
function toViewHjqc() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqc/toViewTabs/view?priNum=" + row.priNum,
        title: "查看",
        width: "60%",
        height: "80%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//查询所有信息
function allInfo(url1) {
    grid.setUrl(url1);
    grid.reload();
}

//无照片指纹
function nomutiInfo(url1) {
    var url = url1 + "&type=4";
    grid.setUrl(url);
    grid.reload();
}

//今日释放
function jinRiShiFang(url1) {
    var url = url1 + "&type=5";
    grid.setUrl(url);
    grid.reload();
}

//未录入狱中表现
function weiLuRuYuZhongBiaoXian(url1) {
    var url = url1 + "&type=6";
    grid.setUrl(url);
    grid.reload();
}

// 未录入危险性评估
function noPingGu(url1) {
    var url = url1 + "&type=7";
    grid.setUrl(url);
    grid.reload();
}

// 帮教对象类别
function bjdxlb(url1, type) {
    var url = url1 + "&type=" + type;
    grid.setUrl(url);
    grid.reload();
}